package com.lp.demo.service.impl;

import com.lp.demo.mapper.OrderMapper;
import com.lp.demo.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OrderService implements IOrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void updateVal(int val) {
        incrByVal(100);
        incrByVal(val);
    }

    @Override
    public void incrByVal(int val) {
        orderMapper.incrByVal(val);
        int a = 1 / 0;
    }

    @Override
    public void decrByVal(int val) {
        orderMapper.decrByVal(val);
    }

}

